<!doctype html>
<html lang="en" data-bs-theme="auto">

<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <meta name="description" content="">
  <title>显示栏目</title>

  <link href="/assets/dist/css/bootstrap.min.css" rel="stylesheet">
  <link rel="stylesheet" href="/assets/icons/font/bootstrap-icons.css">
  <link rel="stylesheet" href="/libs/tree/select-tree.css">
 
  <link href="/css/dashboard.css" rel="stylesheet">
  <script src="/js/jquery.min.js"></script>
  <script src="/libs/tree/select-tree.js"></script>
</head>

<body>

  <div class="container">
    <form class="g-3 mt-1" id="form" method="post">
      <h3>显示栏目</h3>
      <div class="row">
        <div class="col-md-6">
          <label for="title" class="form-label">模块名称</label>
          <input type="text" class="form-control" id="title" name="title" value="<% echo<<obj["info"]["title"].to_string(); %>">
        </div>
      </div>  
      <div class="row">
        <div class="col-md-6">
          <label for="title" class="form-label">显示条目数</label>
          <input type="text" class="form-control" id="rownum" name="rownum" value="<% echo<<obj["info"]["rownum"].to_string(); %>">
        </div>
      </div>  
      <div class="row">
        <div class="col-md-6">
          <label for="title" class="form-label">选择的栏目</label>
          <input type="text" class="form-control" id="topicid_content" name="content" value="<% echo<<obj["info"]["content"].to_string(); %>">
        </div>
      </div>  
      <div class="row">
        <%c for(auto &a:obj["list"].as_array()){ %>
          <div class="row g-3 mt-1">
                <div class="col-md-2">
                  <% echo<<a["title"].to_string(); %>
              </div>
              <div class="col-md-2">
                <input class="form-check-input topicidlist" type="checkbox" role="switch" name="topicid[]" id="topicid_<% echo<<a["topicid"].to_string(); %>" onclick="checktopicinsert(this)" value="<% echo<<a["topicid"].to_string(); %>" <% echo<<a["checked"].to_string(); %>">
              </div>
              
          </div>
           <%c } %> 
 
      </div>  
       
      <div class="row" style="margin-top: 20px;">
        <div class="col-md-6">
        <br />
        <input type="hidden" name="hbid" value="<% echo<<obj["info"]["hbid"].to_string(); %>">
        <input type="hidden" name="viewtype" value="3">
        <button type="submit" class="btn btn-primary">编辑</button>

        <a href="/admin/marhome" class="btn btn-link rounded-pill px-3">返回</a>
        </div>
      </div>
    </form>

  </div>
  
 
 
<div class="modal fade" id="myfiletobigModal" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1" aria-labelledby="staticBackdropLabel" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <h1 class="modal-title fs-5" id="staticBackdropLabel">提示</h1>
        <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
      </div>
      <div class="modal-body">
         文件太大了，请传4M以下的文件！
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">关闭</button>
         
      </div>
    </div>
  </div>
</div> 

  
  <script src="/assets/dist/js/bootstrap.bundle.min.js"></script>
  <script lang="javascript">

     function gotourl()
    {
        window.location.href='/admin/marhome';
    }
    $("#form").on("submit", function (event) {
      event.preventDefault();
      var data = $(this).serialize();

      var obj=this;  
      //得到序列化数据
      $.ajax({
        url: "/admin/edithomeblockpost",
        method: 'post',
        contentType:"application/x-www-form-urlencoded",
        data: data,
        dataType: "json"
        }).done(function(data) {
          if(data.code==0)
          {
             setTimeout("gotourl()",500 );  
          }
        });
    });
    
    function checktopicinsert(obj)
    {
 
      var topicidstr=$("#topicid_content").val();
      if(jQuery(obj).is(":checked"))
        {
            if(topicidstr.length>0)
            {
              topicidstr=topicidstr+","+jQuery(obj).val();
            }else{
              topicidstr=jQuery(obj).val();
            }
            
        }else{
          var artArray = topicidstr.split(",");   
          for (var i = 0; i < artArray.length; i++) {
            if (artArray[i] == jQuery(obj).val()) {
              artArray.splice(i, 1);  //删除第i项
            }
          }
          topicidstr = artArray.join(",");
        }
        $("#topicid_content").val(topicidstr);
    }
    
    
 

    $(document).ready(function(e) {
         

 
    });
  </script>
</body>

</html>